package com.enki.cigarettes.utils.wechatpay;

import com.enki.cigarettes.utils.wechatpay.pay.sdk.IWXPayDomain;
import com.enki.cigarettes.utils.wechatpay.pay.sdk.WXPayConfig;

import java.io.InputStream;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author WCS.Wang
 * @version V1.0
 * @Package com.enki.cigarettes.utils.wechatpay
 * @Name e-cigarettes-shop-api-module
 * @Description: TODO 小程序支付参数配置
 * @date 2019-07-21
 */
public class WXJSAPIPayConfigImpl  implements WXPayConfig {

    private static WXJSAPIPayConfigImpl INSTANCE;

    public static WXJSAPIPayConfigImpl getInstance() throws Exception {
        if (INSTANCE == null) {
            synchronized (WXJSAPIPayConfigImpl.class) {
                if (INSTANCE == null) {
                    INSTANCE = new WXJSAPIPayConfigImpl();
                }
            }
        }
        return INSTANCE;
    }

    @Override
    public String getAppID() {
        return "wx0ca1211945d35f50";
    }

    @Override
    public String getMchID() {
        return "1525547981";
    }

    @Override
    public String getKey() {
        return "SHsishuxinxikejiyouxiangongsi320";
    }

    @Override
    public InputStream getCertStream() {
        return null;
    }

    @Override
    public int getHttpConnectTimeoutMs() {
        return 6 * 1000;
    }

    @Override
    public int getHttpReadTimeoutMs() {
        return 8 * 1000;
    }

    @Override
    public IWXPayDomain getWXPayDomain() {
        return IWXPayDomainImpl.instance();
    }

    @Override
    public boolean shouldAutoReport() {
        return true;
    }

    @Override
    public int getReportWorkerNum() {
        return 6;
    }

    @Override
    public int getReportQueueMaxSize() {
        return 10000;
    }

    @Override
    public int getReportBatchSize() {
        return 10;
    }

    @Override
    public String getTradeType() {
        return "JSAPI";
    }

    @Override
    public String getNotifyUrl() {
        return "https://www.enkivapor.com.cn/";
    }

    @Override
    public String getHostIP() {
        InetAddress addr;
        String ip = "";
        try {
            addr = InetAddress.getLocalHost();
            ip = addr.getHostAddress().toString(); //获取本机ip
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return ip;
    }

    @Override
    public String getSignType() {
        return "MD5";
    }
}